export function removeLableAndImage(html) {
	let msg = html.replace(/<(p|div)[^>]*>(<br\/?>|&nbsp;)<\/\1>/gi, '\n')
		.replace(/<br\/?>/gi, '\n').replace(/<[^>/]+>/g, '')
		.replace(/(\n)?<\/([^>]+)>/g, '').replace(/\u00a0/g, ' ')
		.replace(/&nbsp;/g, ' ').replace(/<\/?(img)[^>]*>/gi, '')
		.replace(/&amp;/g, "&").replace(/&lt;/g, "<")
		.replace(/&gt;/g, ">")
		.replace(/&#39;/g, "\'")
		.replace(/&quot;/g, "\"")
		.replace(/<\/?.+?>/g, "")
	return msg
}


export function pullAuthFun(scope, callback, callback2) {
	const map = new Map([
		['scope.userInfo', '用户信息'],
		['scope.userLocation', '地理位置'],
		['scope.userLocationBackground', '后台定位'],
		['scope.address', '通信地址'],
		['scope.record', '录音功能'],
		['scope.writePhotosAlbum', '保存到相册'],
		['scope.camera', '摄像头'],
		['scope.invoice', '获取发票'],
		['scope.invoiceTitle', '发票抬头'],
		['scope.werun', '微信运动步数'],
	])
	uni.getSetting({
		success(res) {
			if (!res.authSetting[scope]) {
				uni.authorize({
					scope,
					success() { // 允许授权
						callback2()
					},
					fail() { // 拒绝授权
						if (map.has(scope)) {
							callback()
						} else {
							uni.showToast({
								title: '无此授权功能',
								icon: 'none',
							})
							// callback()
						}
					},
				})
			} else {
				callback2()
			}
		},
	})
}


